package com.hrw.musicplayer.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.Gallery.LayoutParams;

import com.hrw.musicplayer.R;

public class ImageAdapter extends BaseAdapter {
	protected Integer[] mThumbIds = { R.drawable.speaker1, R.drawable.speaker2,
			R.drawable.speaker3, R.drawable.speaker4, R.drawable.speaker5,
			R.drawable.speaker6, R.drawable.speaker7, R.drawable.speaker8 };
	private Context mContext;

	public ImageAdapter(Context c) {
		mContext = c;
	}

	public int getCount() {
		return mThumbIds.length;
	}

	public Object getItem(int position) {
		return position;
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		ImageView i = new ImageView(mContext);
		if (position < 0) {

			position = position + getCount();

		}
		i.setImageResource(mThumbIds[position % getCount()]);

		i.setAdjustViewBounds(true);
		i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT,
				LayoutParams.WRAP_CONTENT));
		// i.setBackgroundResource(R.drawable.background);
		return i;
	}

}
